#pragma once

#include "MSphere.h"
#include "MCube.h"
#include "MCylinder.h"
#include "MTorus.h"
#include "MCone.h"
#include "MMesh.h"
#include "MStar.h"
#include <GL\glut.h>
#include <stdio.h>
#include "MSphere.h"
using namespace std;


/* define index constants into the colors array */
#define BLACK   0
#define RED     1
#define YELLOW  2
#define MAGENTA 3
#define GREEN   4
#define CYAN    5
#define BLUE    6
#define GREY    7
#define WHITE   8


#define HOUSE    0
#define CUBE     1
#define TESCUBE  2
#define CYLINDER 3
#define SPHERE   4
#define TORUS    5
#define MESH     6
#define GEODESIC 7
#define CONE 8
#define MESH1 9
#define MESH2 10
#define MESH3 11
#define STAR 12

const GLfloat colors [][3] = {
  {0.0, 0.0, 0.0},  /* black   */
  {1.0, 0.0, 0.0},  /* red     */
  {1.0, 1.0, 0.0},  /* yellow  */
  {1.0, 0.0, 1.0},  /* magenta */
  {0.0, 1.0, 0.0},  /* green   */
  {0.0, 1.0, 1.0},  /* cyan    */
  {0.0, 0.0, 1.0},  /* blue    */
  {0.5, 0.5, 0.5},  /* 50%grey */
  {1.0, 1.0, 1.0}   /* white   */
};

/*note the 4 (!) coordinates per vertex below; 
homogeneous coords with w = 1 (see the lecture notes);*/
const GLfloat vertices_house[][4] = {
  {0,2,0,1}, 
  {-1,1,1,1}, {1,1,1,1}, {1,1,-1,1}, {-1,1,-1,1},
  {-1,-1,1,1}, {1,-1,1,1}, {1,-1,-1,1}, {-1,-1,-1,1}
};


const GLfloat vertices_cube_brute[][4] = {
  {-1,1,1,1}, {1,1,1,1}, {1,1,-1,1}, {-1,1,-1,1},
  {-1,-1,1,1}, {1,-1,1,1}, {1,-1,-1,1}, {-1,-1,-1,1}
  };


class SceneManager
{
private:
	static int theta_x;
	static int theta_y;
	static int crt_render_mode;
	static int crt_shape, crt_rs, crt_vs;
	static double cyl_height;
	static double cyl_ray;
	static double sph_ray;
	static MSphere *sphere;
	static MTorus *donut;
	static MCylinder * cylinder;
	static MCone *cone;
	static MMesh *monster;
	static MMesh *dragon;
	static MMesh *teapot;
	static MCube *cube;
	static MStar *star;
	static Shape *shape;
public:
	static int my_glmain(int, char **);
private:
	SceneManager();
	~SceneManager(void);
	static void my_glutsetup();
	static void my_glsetup();
	static void my_setup();
	static void my_display();
	static void my_timeout(int id);
	static void my_idle();
	static void my_reshape(int w, int h);
	static void my_mouse(int b, int s, int x, int y);
	static void my_keyboard(unsigned char c, int x, int y);
	static void draw_house();
	static void draw_cube_brute();
	static void draw_triangle(const MVertex &p1,  const MVertex &p2, const MVertex &p3, int ic);
	static void draw_triangle(const GLfloat vertices[][4], int iv1, int iv2, int iv3, int ic);
	static void draw_line(const MVertex &p1,  const MVertex &p2,int ic);
	static void draw_quad(const GLfloat vertices[][4], int iv1, int iv2, int iv3, int iv4, int ic);
	static void draw_param_quad(GLfloat vertices[][50][4], int line, int col, int ic);
	static void draw_poly(const vector<MVertex> &v1, int ic);
	static void cleanupExit();
};

